package com.HuangJiaQing.www.controller;

import com.HuangJiaQing.www.model.Bill;
import com.HuangJiaQing.www.model.Courier;
import com.HuangJiaQing.www.service.CourierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @author HONOR
 * @date 2022/8/6 11:21
 */
@Controller
public class CourierController {
    @Autowired
    private CourierService courierService;

    @RequestMapping(value = "/toRegistCourier",method = RequestMethod.GET)
    public String toRegisterCourier(){
        return "registCourier";
    }

    @RequestMapping(value = "/registCourier",method = RequestMethod.POST)
    public String registerCourier(Courier courier){
        boolean b = courierService.registerCourier(courier);
        if (b){
            return "login";
        }else {
            return "registCourier";
        }
    }

    @RequestMapping("/courierLogin")
    public String courierLogin(Model model){
        List<Bill> bills = courierService.courierLogin();
        model.addAttribute("bills",bills);
        return "courier";
    }
}
